home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / USB / Mac OS USB DDK v1.2 / Examples / USBSampleStorageDriver / StorageClassUTDriverIcons.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-15  |  5.8 KB  |  168 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        StorageClassUTDriverIcons.h
  3.  
  4.     Contains:    All declarations and types that are associated with the 
  5.                 Driver's Drive and Media Icons.
  6.  
  7.     Version:    1.1
  8.     
  9.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11. */
  12.  
  13.  
  14. #ifndef __STORAGECLASSUTDRIVERICONS__
  15. #define __STORAGECLASSUTDRIVERICONS__
  16.  
  17. #include <MacTypes.h>
  18. #include <Icons.h>
  19.  
  20. #if UNIVERSAL_INTERFACES_VERSION < 0x0320
  21.  
  22. // Start of Universal Headers 3.2 Defintions **************************************************
  23. // The following structures are from the Prerelease of Universal Headers 3.2
  24.  
  25. // These are the new DriverGestalts for return color icons
  26. // These should be removed when upgrading to the Universal Headers 3.2.
  27. enum
  28. {
  29.     kdgPhysDriveIconSuite        = FOUR_CHAR_CODE('dics'),        /* Return a pointer to a IconFamily ('icns') data structure for */
  30.                                                                 /* Disk Driver physical drive (formerly in csCode 22) in driverGestaltResponse. */
  31.     kdgMediaIconSuite            = FOUR_CHAR_CODE('mics'),        /* Return a pointer to a IconFamily ('icns') data structure for */
  32.                                                                 /* Disk Driver media (formerly in csCode 21) in driverGestaltResponse. */
  33.                                                                 /* See IconServices.r for information detailing the 'icns' resource data format */
  34.     kdgMediaName                = FOUR_CHAR_CODE('mnam')        /* Return a pointer to a pascal string describing the Disk Driver (formerly in csCode 21) in driverGestaltResponse. */
  35. };
  36.  
  37. // These support the new 'icns' icon family structures.
  38. // These should be removed once the Headers are updated to UH 3.2
  39.  
  40. /* IconRefs are 32-bit values identifying cached icon data. IconRef 0 is invalid.*/
  41. typedef struct OpaqueIconRef*             IconRef;
  42.  
  43. /*
  44.       IconFamily 'icns' resources contain an entire IconFamily (all sizes and depths).  
  45.    For custom icons, icns IconFamily resources of the custom icon resource ID are fetched first before
  46.    the classic custom icons (individual 'ics#, ICN#, etc) are fetched.  If the fetch of the icns resource
  47.    succeeds then the icns is looked at exclusively for the icon data.
  48.    For custom icons, new icon features such as 32-bit deep icons are only fetched from the icns resource.
  49.    This is to avoid incompatibilities with cut & paste of new style icons with an older version of the
  50.    MacOS Finder.
  51.    DriverGestalt is called with code kdgMediaIconSuite by IconServices after calling FSM to determine a
  52.    driver icon for a particular device.  The result of the kdgMediaIconSuite call to DriverGestalt should
  53.    be a pointer an an IconFamily.  In this manner driver vendors can provide rich, detailed drive icons
  54.    instead of the 1-bit variety previously supported.
  55. */
  56.  
  57. enum {
  58.     kIconFamilyType                = FOUR_CHAR_CODE('icns')
  59. };
  60.  
  61.  
  62.  
  63. struct IconFamilyElement {
  64.     OSType                             elementType;                /* 'ICN#', 'icl8', etc...*/
  65.     Size                             elementSize;                /* Size of this element*/
  66.     unsigned char                     elementData[1];
  67. };
  68. typedef struct IconFamilyElement        IconFamilyElement;
  69.  
  70. struct IconFamilyResource {
  71.     OSType                             resourceType;                /* Always 'icns'*/
  72.     Size                             resourceSize;                /* Total size of this resource*/
  73.     IconFamilyElement                 elements[1];
  74.  
  75. };
  76. typedef struct IconFamilyResource        IconFamilyResource;
  77.  
  78. typedef IconFamilyResource *            IconFamilyPtr;
  79. typedef IconFamilyPtr *                    IconFamilyHandle;
  80.  
  81. /*
  82.    Use the special creator kSystemIconsCreator to get "standard" icons 
  83.    that are not associated with a file, such as the help icon.
  84. */
  85.  
  86. enum {
  87.     kSystemIconsCreator            = FOUR_CHAR_CODE('macs')
  88. };
  89.  
  90. enum {
  91.     kGenericFloppyIcon            = FOUR_CHAR_CODE('flpy')
  92. };
  93.  
  94. #endif    // UNIVERSAL_INTERFACES_VERSION < 0x0320
  95.  
  96. /*
  97.    IconRefToIconFamily
  98.    This routines returns a new IconFamily that contains the data corresponding
  99.    to the specified IconRef
  100. */
  101.  
  102. EXTERN_API( OSErr )
  103. IconRefToIconFamily                (IconRef                 theIconRef,
  104.                                  IconSelectorValue         whichIcons,
  105.                                  IconFamilyHandle *        iconFamily)                            TWOWORDINLINE(0x7024, 0xAA75);
  106.  
  107.  
  108. /*
  109.    GetIconRef
  110.    
  111.    This routine returns an icon ref for an icon in the desktop database or
  112.    for a registered icon.
  113.    The system registers a set of icon such as the help icon with the creator 
  114.    code kSystemIconCreator. See above for a list of the registered system types.
  115.    The vRefNum is used as a hint on where to look for the icon first. Use 
  116.    kOnSystemDisk if you don't know what to pass.
  117.    This routine increments the reference count of the returned IconRef. Call 
  118.    ReleaseIconRef() when you're done with it.
  119. */
  120.  
  121. EXTERN_API( OSErr )
  122. GetIconRef                        (SInt16                 vRefNum,
  123.                                  OSType                 creator,
  124.                                  OSType                 iconType,
  125.                                  IconRef *                theIconRef)                            TWOWORDINLINE(0x7021, 0xAA75);
  126.  
  127.  
  128. /*
  129.    ReleaseIconRef
  130.    
  131.    This routine decrements the reference count for the IconRef.
  132.    
  133.    When the reference count reaches 0, all memory allocated for the icon
  134.    is disposed. Any subsequent use of the IconRef is invalid.
  135. */
  136.  
  137. EXTERN_API( OSErr )
  138. ReleaseIconRef                    (IconRef                 theIconRef)                            TWOWORDINLINE(0x7028, 0xAA75);
  139. // End of Universal Headers 3.2 prerelease info ****************************************
  140.  
  141. // Device location icon/string structure format
  142. struct DriverLocationIcon    
  143. {
  144.     SInt8    LocationIcon[256];        // ICN# data is 256 bytes 
  145.     Str255    LocationString;            // returned in C string format
  146. };
  147. typedef struct DriverLocationIcon DriverLocationIcon;
  148.  
  149.  
  150. // These structures are for the Black and white 1 bit icons
  151. typedef SInt16             DiskIcon[128];    // Structure for disk icon data (256 bytes)
  152.  
  153. extern DiskIcon         CartridgeIcon;
  154. extern DiskIcon         AppleFloppyMediaIcon;
  155.  
  156. // These variables are used for color icon support.
  157. // They will be set to nil if the IconServicesLib couldn't be found
  158. extern IconFamilyPtr    CartridgeMediaIconFamily;
  159. extern IconFamilyHandle    FloppyMediaIconFamily;
  160.  
  161. // Function call to create the color icon families
  162. extern void BuildMediaIconFamily( void );
  163.  
  164. // Function call to remove the color icon families and reclaim any memory
  165. extern void DestroyMediaIconFamily( void );
  166.  
  167. #endif /* __STORAGECLASSUTDRIVERICONS__ */
  168.